<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddColumnReport251001 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //日报表
        Schema::table('daily_report', function (Blueprint $table){
            $table->integer('active_ct')->default(0)->comment('活跃人数');
            $table->integer('classify_ct')->default(0)->comment('选择分类继续人数');
            $table->integer('un_book_ct')->default(0)->comment('当日注册未选择书的人数');
        });

        //用户表
        Schema::table('users', function (Blueprint $table){
            $table->integer('classify_id')->index()->default(0)->comment('分类ID');
            $table->date('classify_date')->index()->nullable()->comment('首次选择分类的时间');
        });

        //订单表
        Schema::table('orders', function (Blueprint $table){
            $table->integer('book_id')->default(0)->comment('所在书籍的提交');
        });

        //日报表-书本
        Schema::create('daily_book', function (Blueprint $table){
            $table->increments('id');
            $table->date('date')->index()->default('2025-09-10')->comment('日期');
            $table->integer('book_id')->default(0)->comment('书籍ID');
            $table->integer('active_ct')->default(0)->comment('访问人数');
            $table->integer('new_ct')->default(0)->comment('新用户数');
            $table->integer('auth_ct')->default(0)->comment('授权人数');
            $table->integer('pay_ct')->default(0)->comment('付费人数');
            $table->integer('pay_chapter_ct')->default(0)->comment('单章节购买人数');
            $table->integer('pay_all_chapter_ct')->default(0)->comment('剩余章节购买人数');
            $table->integer('member_ct')->default(0)->comment('大会员购买人数');
            $table->integer('income')->default(0)->comment('合计收入');

            $table->timestamps();
            $table->unique(['book_id', 'date']);
        });

        //书本表
        Schema::table('book', function (Blueprint $table){
            $table->integer('active_ct')->default(0)->comment('访问人数');
            $table->integer('new_ct')->default(0)->comment('新用户数');
            $table->integer('auth_ct')->default(0)->comment('授权人数');
            $table->integer('pay_ct')->default(0)->comment('付费人数');
            $table->integer('pay_chapter_ct')->default(0)->comment('单章节购买人数');
            $table->integer('pay_all_chapter_ct')->default(0)->comment('剩余章节购买人数');
            $table->integer('member_ct')->default(0)->comment('大会员购买人数');
            $table->integer('income')->default(0)->comment('合计收入');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
